using System;
using System.Windows.Forms;
using System.Drawing;

namespace HIS
{
    public class MedicalOrderForm : Form
    {
        private TabControl tabControl;
        private TabPage tabMedicine;
        private TabPage tabTreatment;
        private TabPage tabExamination;
        private TabPage tabLaboratory;

        public MedicalOrderForm()
        {
            InitializeComponents();
        }

        private void InitializeComponents()
        {
            // 窗体设置
            this.Text = "门诊医嘱";
            this.Size = new Size(1000, 700);
            this.StartPosition = FormStartPosition.CenterScreen;

            // 创建选项卡控件
            tabControl = new TabControl
            {
                Location = new Point(20, 20),
                Size = new Size(960, 660)
            };

            // 药品处方选项卡
            tabMedicine = new TabPage("药品处方");
            InitializeMedicineTab();

            // 治疗单选项卡
            tabTreatment = new TabPage("治疗单");
            InitializeTreatmentTab();

            // 检查申请单选项卡
            tabExamination = new TabPage("检查申请单");
            InitializeExaminationTab();

            // 检验申请单选项卡
            tabLaboratory = new TabPage("检验申请单");
            InitializeLaboratoryTab();

            // 添加选项卡
            tabControl.TabPages.AddRange(new TabPage[] {
                tabMedicine,
                tabTreatment,
                tabExamination,
                tabLaboratory
            });

            // 添加控件到窗体
            this.Controls.Add(tabControl);
        }

        private void InitializeMedicineTab()
        {
            // 模板选择区域
            GroupBox gbTemplate = new GroupBox
            {
                Text = "医嘱模板",
                Location = new Point(10, 10),
                Size = new Size(920, 60)
            };

            ComboBox cmbTemplate = new ComboBox
            {
                Location = new Point(10, 25),
                Size = new Size(200, 25),
                DropDownStyle = ComboBoxStyle.DropDownList
            };
            cmbTemplate.Items.AddRange(new string[] { "个人模板", "科室模板", "全院模板" });

            Button btnCopyHistory = new Button
            {
                Text = "复制历史记录",
                Location = new Point(220, 25),
                Size = new Size(100, 25)
            };

            gbTemplate.Controls.AddRange(new Control[] { cmbTemplate, btnCopyHistory });

            // 药品选择区域
            GroupBox gbMedicine = new GroupBox
            {
                Text = "药品信息",
                Location = new Point(10, 80),
                Size = new Size(920, 200)
            };

            // 药品选择
            Label lblMedicine = new Label
            {
                Text = "药品：",
                Location = new Point(10, 25),
                AutoSize = true
            };

            ComboBox cmbMedicine = new ComboBox
            {
                Location = new Point(60, 22),
                Size = new Size(300, 25)
            };

            // 剂量、用法、频率、疗程
            Label lblDosage = new Label
            {
                Text = "剂量：",
                Location = new Point(10, 60),
                AutoSize = true
            };

            TextBox txtDosage = new TextBox
            {
                Location = new Point(60, 57),
                Size = new Size(100, 25)
            };

            Label lblUsage = new Label
            {
                Text = "用法：",
                Location = new Point(170, 60),
                AutoSize = true
            };

            TextBox txtUsage = new TextBox
            {
                Location = new Point(220, 57),
                Size = new Size(100, 25)
            };

            Label lblFrequency = new Label
            {
                Text = "频率：",
                Location = new Point(330, 60),
                AutoSize = true
            };

            TextBox txtFrequency = new TextBox
            {
                Location = new Point(380, 57),
                Size = new Size(100, 25)
            };

            Label lblCourse = new Label
            {
                Text = "疗程：",
                Location = new Point(490, 60),
                AutoSize = true
            };

            TextBox txtCourse = new TextBox
            {
                Location = new Point(540, 57),
                Size = new Size(100, 25)
            };

            // 中草药方剂编辑区域
            TextBox txtHerbalPrescription = new TextBox
            {
                Location = new Point(10, 100),
                Size = new Size(900, 80),
                Multiline = true
            };

            gbMedicine.Controls.AddRange(new Control[] {
                lblMedicine, cmbMedicine,
                lblDosage, txtDosage,
                lblUsage, txtUsage,
                lblFrequency, txtFrequency,
                lblCourse, txtCourse,
                txtHerbalPrescription
            });

            // 操作按钮
            Button btnInsert = new Button
            {
                Text = "插入",
                Location = new Point(10, 290),
                Size = new Size(80, 30)
            };

            Button btnModify = new Button
            {
                Text = "修改",
                Location = new Point(100, 290),
                Size = new Size(80, 30)
            };

            Button btnDelete = new Button
            {
                Text = "删除",
                Location = new Point(190, 290),
                Size = new Size(80, 30)
            };

            Button btnApprove = new Button
            {
                Text = "审核",
                Location = new Point(280, 290),
                Size = new Size(80, 30)
            };

            // 添加控件到选项卡
            tabMedicine.Controls.AddRange(new Control[] {
                gbTemplate,
                gbMedicine,
                btnInsert,
                btnModify,
                btnDelete,
                btnApprove
            });
        }

        private void InitializeTreatmentTab()
        {
            // 治疗项目输入区域
            GroupBox gbTreatment = new GroupBox
            {
                Text = "治疗项目",
                Location = new Point(10, 10),
                Size = new Size(920, 200)
            };

            Label lblTreatment = new Label
            {
                Text = "治疗项目：",
                Location = new Point(10, 25),
                AutoSize = true
            };

            TextBox txtTreatment = new TextBox
            {
                Location = new Point(90, 22),
                Size = new Size(300, 25)
            };

            // 治疗项目列表
            DataGridView dgvTreatmentList = new DataGridView
            {
                Location = new Point(10, 60),
                Size = new Size(900, 130),
                AllowUserToAddRows = false,
                AllowUserToDeleteRows = false,
                ReadOnly = true
            };

            dgvTreatmentList.Columns.AddRange(new DataGridViewColumn[] {
                new DataGridViewTextBoxColumn { Name = "治疗项目", HeaderText = "治疗项目", Width = 200 },
                new DataGridViewTextBoxColumn { Name = "数量", HeaderText = "数量", Width = 100 },
                new DataGridViewTextBoxColumn { Name = "单价", HeaderText = "单价", Width = 100 }
            });

            gbTreatment.Controls.AddRange(new Control[] {
                lblTreatment,
                txtTreatment,
                dgvTreatmentList
            });

            // 添加控件到选项卡
            tabTreatment.Controls.Add(gbTreatment);
        }

        private void InitializeExaminationTab()
        {
            // 检查项目选择区域
            GroupBox gbExamination = new GroupBox
            {
                Text = "检查项目",
                Location = new Point(10, 10),
                Size = new Size(920, 200)
            };

            Label lblExamination = new Label
            {
                Text = "检查项目：",
                Location = new Point(10, 25),
                AutoSize = true
            };

            ComboBox cmbExamination = new ComboBox
            {
                Location = new Point(90, 22),
                Size = new Size(300, 25),
                DropDownStyle = ComboBoxStyle.DropDownList
            };
            cmbExamination.Items.AddRange(new string[] { "组合检查", "单项检查" });

            // 检查项目列表
            DataGridView dgvExaminationList = new DataGridView
            {
                Location = new Point(10, 60),
                Size = new Size(900, 130),
                AllowUserToAddRows = false,
                AllowUserToDeleteRows = false,
                ReadOnly = true
            };

            dgvExaminationList.Columns.AddRange(new DataGridViewColumn[] {
                new DataGridViewTextBoxColumn { Name = "检查项目", HeaderText = "检查项目", Width = 200 },
                new DataGridViewTextBoxColumn { Name = "检查部位", HeaderText = "检查部位", Width = 150 },
                new DataGridViewTextBoxColumn { Name = "检查方法", HeaderText = "检查方法", Width = 150 }
            });

            gbExamination.Controls.AddRange(new Control[] {
                lblExamination,
                cmbExamination,
                dgvExaminationList
            });

            // 智能提醒区域
            GroupBox gbReminder = new GroupBox
            {
                Text = "智能提醒",
                Location = new Point(10, 220),
                Size = new Size(920, 100)
            };

            TextBox txtReminder = new TextBox
            {
                Location = new Point(10, 25),
                Size = new Size(900, 60),
                Multiline = true,
                ReadOnly = true
            };

            gbReminder.Controls.Add(txtReminder);

            // 添加控件到选项卡
            tabExamination.Controls.AddRange(new Control[] {
                gbExamination,
                gbReminder
            });
        }

        private void InitializeLaboratoryTab()
        {
            // 检验项目选择区域
            GroupBox gbLaboratory = new GroupBox
            {
                Text = "检验项目",
                Location = new Point(10, 10),
                Size = new Size(920, 300)
            };

            Label lblLaboratory = new Label
            {
                Text = "检验项目：",
                Location = new Point(10, 25),
                AutoSize = true
            };

            ComboBox cmbLaboratory = new ComboBox
            {
                Location = new Point(90, 22),
                Size = new Size(300, 25)
            };

            // 检验组合分类显示区域
            TreeView tvLaboratory = new TreeView
            {
                Location = new Point(10, 60),
                Size = new Size(900, 230)
            };

            gbLaboratory.Controls.AddRange(new Control[] {
                lblLaboratory,
                cmbLaboratory,
                tvLaboratory
            });

            // 添加控件到选项卡
            tabLaboratory.Controls.Add(gbLaboratory);
        }
    }
} 